import 'package:kasax_demos2/netio/request_dios.dart';
import 'package:kasax_demos2/gankio/entry/girl_category_result_entity.dart';
import 'package:kasax_demos2/gankio/entry/girl_sub_category_result_entity.dart';

import 'entry_banner.dart';

/// https://gank.io/
/// https://gank.io/api
class GankIoApiProvider {
  static final GankIoApiProvider _instance = GankIoApiProvider._internal();

  factory GankIoApiProvider() => _instance;

  static GankIoApiProvider getInstance() => _instance;

  GankIoApiProvider._internal();

  /// 首页banner轮播
  Future<List<BannerItem>> getBannerList() {
    return DioManager.getInstance().fetchBanners();
  }

  /// 分类 API
  /// 参数： category_type 可接受参数 Article | GanHuo | Girl
  // Article: 专题分类、 GanHuo: 干货分类 、 Girl:妹子图
  Future<GirlCategoryResultEntity> featCategories(String category_type) =>
      DioManager.getInstance().featCategories(category_type);

  /// 分类数据 API
  /// category 可接受参数 All(所有分类) | Article | GanHuo | Girl
  // type 可接受参数 All(全部类型) | Android | iOS | Flutter | Girl ...，即分类API返回的类型数据
  // count: [10, 50]
  // page: >=1
  Future<GirlSubCategoryResultEntity> featBatchCategory(String category, String type, int page, int count) =>
      DioManager.getInstance().featBatchCategory(category, type, page, count);

  /// 随机 API
  /// 获取干货分类下Android子分类的10个随机文章列表
  // https://gank.io/api/v2/random/category/GanHuo/type/Android/count/10
  Future featRandomCategory(
          String category, String type, int page, int count) =>
      DioManager.getInstance().featRandomCategory(category, type, page, count);

  /// 文章详情 API
  /// 获取5e777432b8ea09cade05263f的详情数据
  // https://gank.io/api/v2/post/5e777432b8ea09cade05263f
  Future featPost(String post_id) async {}

  /// 本周最热 API
  /// hot_type 可接受参数 views（浏览数） | likes（点赞数） | comments（评论数）❌
  // category 可接受参数 Article | GanHuo | Girl
  // count: [1, 20]
  Future featHot(String hot_type, String category, int count) =>
      DioManager.getInstance().featHot(hot_type, category, count);

  /// 文章评论获取 API
  Future featComments(String post_id) =>
      DioManager.getInstance().featComments(post_id);

  /// 搜索 API
  /// search 可接受参数 要搜索的内容
  // category 可接受参数 All[所有分类] | Article | GanHuo
  // type 可接受参数 Android | iOS | Flutter ...，即分类API返回的类型数据
  // count: [10, 50]
  // page: >=1
  Future search(
          String search, String category, String type, int page, int count) =>
      DioManager.getInstance().search(search, category, type, page, count);
}
